#pragma once

#include <string>
#include <vector>
#include <boost/format.hpp>

using std::vector;
using std::string;

namespace libzq
{
	void split(const string& in, vector<string>& str_vec, const char* sign);
	vector<string> split(const string& in, const char* sign);
	string join(const vector<string>& in, const char* sign);
	string join(vector<string>::const_iterator begin, vector<string>::const_iterator end, const char* sign);

	string GB2312ToUTF_8(const string& in);
	string UTF_8ToGB2312(const string& in);
	string make_uuid();
	string stacktrace();

	template<class T>
	void format(boost::format& fmt, const T t)
	{
		fmt % t;
	}

	template<class T1, class... T2>
	void format(boost::format& fmt, const T1 t1, const T2... t2)
	{
		fmt % t1;
		format(fmt, t2...);
	}

	template<class... T>
	string format(const char* fmt, const T... t)
	{
		boost::format fmt_(fmt);
		format(fmt_, t...);
		return std::move(fmt_.str());
	}
}